package com.yk._11流失计算;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class StreamDemo {



    public static void main(String[] args) {
        ArrayList<Student> students = new ArrayList<Student>() {{
            Student stu1 = new Student("a", 15, 160);
            Student stu2 = new Student("a", 16, 170);
            Student stu3 = new Student("a", 17, 180);
            Student stu4 = new Student("a", 18, 190);
            Student stu5 = new Student("a", 19, 200);
            add(stu1);
            add(stu2);
            add(stu3);
            add(stu4);
            add(stu5);
        }};
        students.stream().filter((student) -> {
            return student.getHeight() > 170;
        }).filter((student) -> {
            return student.getAge() > 15;
        }).limit(1).forEach((student)->{
            System.out.println("student = " + student);
        });
    }
}

@Data
@NoArgsConstructor
@AllArgsConstructor
class Student{
    private String name;
    private Integer age;
    private Integer height;
}



